Expand description
This package contains the C-ABI of Relay. It builds a C header file and
associated library that can be linked to any C or C++ program. Note that the
header is C only. Primarily, this package is meant to be consumed by
higher-level wrappers in other languages, such as the
sentry-relay
Python package.
§Building
Building the dynamic library has the same requirements as building the
relay
crate:
- Latest stable Rust and Cargo
- A checkout of this repository and all its GIT submodules
To build, run make release
in this directory. This creates a release build of
the dynamic library in target/release/librelay_cabi.*
.
§Usage
The header comes packaged in the include/
directory. It does not have any
dependencies other than standard C headers. Then, include it in sources and use
like this:
#include "relay.h"
int main() {
RelayUuid uuid = relay_generate_relay_id();
// use uuid
return 0;
}
In your application, point to the Relay include directory and specify the
relay
library:
$(CC) -Irelay-cabi/include -Ltarget/release -lrelay -o myprogram main.c
§Development
§Requirements
In addition to the build requirements, development requires a recent version
of the the cbindgen
tool. To set this up, run:
cargo install cbindgen
If your machine already has cbindgen
installed, check the header of
[include/relay.h
] for the minimum version required. This can be verified by
running cbindgen --version
. It is generally advisable to keep cbindgen
updated to its latest version, and always check in cbindgen updates separate
from changes to the public interface.
§Makefile
This package contains the Rust crate relay-cabi
that exposes a public FFI
interface. There are additional build steps involved in generating the header
file located at include/relay.h
. To aid development, there is a Makefile
that exposes all relevant commands for building:
make build
: Builds the library usingcargo
.make header
: Updates the header file based on the public interface.make clean
: Removes all build artifacts but leaves the header.make
: Builds the library and the header.
For ease of development, the header is always checked into the repository. After
making changes, do not forget to run at least make header
to ensure the header
is in sync with the library.
§Development Flow
- Make changes to the
relay
crates and add tests. - Update
relay-cabi
and add, remove or update functions as needed. - Regenerate the header by running
make header
in therelay-cabi/
directory. - Go to the Python package in the
py/
folder and update the high-level wrappers. - Consider whether this changeset requires a major version bump.
The general rule for major versions is:
- If everything is backward compatible, do not major bump.
- If the C interface breaks compatibility but high-level wrappers are still backwards compatible, do not major bump. The C interface is currently viewed as an implementation detail.
- If high-level wrappers are no longer backwards compatible or there are
breaking changes in the
relay
crate itself, do major bump.
Structs§
- Relay
Buf - A binary buffer of known length.
- Relay
GeoIp Lookup - A geo ip lookup helper based on maxmind db files.
- Relay
KeyPair - Represents a key pair from key generation.
- Relay
Public Key - Represents a public key in Relay.
- Relay
Register Request - Represents a register request.
- Relay
Secret Key - Represents a secret key in Relay.
- Relay
Store Normalizer - The processor that normalizes events for store.
- Relay
Str - A length-prefixed UTF-8 string.
- Relay
Uuid - A 16-byte UUID.
- Store
Normalizer - Configuration for the store step – validation and normalization.
Enums§
- Data
Category - Classifies the type of data that is being ingested.
- Event
Type - The type of an event.
- Glob
Flags - Controls the globbing behaviors.
- Relay
Error Code - Represents all possible error codes.
- Span
Status - Trace status.
Functions§
- normalize_
cardinality_ ⚠limit_ config - Normalize a cardinality limit config.
- relay_
buf_ ⚠free - Frees a Relay buf.
- relay_
compare_ ⚠versions - Compares two versions.
- relay_
convert_ ⚠datascrubbing_ config - Convert an old datascrubbing config to the new PII config format.
- relay_
create_ ⚠register_ challenge - Creates a challenge from a register request and returns JSON.
- relay_
data_ ⚠category_ from_ event_ type - Parses a
DataCategory
from an event type. - relay_
data_ ⚠category_ name - Returns the API name of the given
DataCategory
. - relay_
data_ ⚠category_ parse - Parses a
DataCategory
from its API name. - relay_
err_ clear - Clears the last error.
- relay_
err_ get_ backtrace - Returns the panic information as string.
- relay_
err_ get_ last_ code - Returns the last error code.
- relay_
err_ get_ last_ message - Returns the last error message.
- relay_
generate_ ⚠key_ pair - Generates a secret, public key pair.
- relay_
generate_ ⚠relay_ id - Randomly generates an relay id
- relay_
geoip_ ⚠lookup_ free - Frees a
RelayGeoIpLookup
. - relay_
geoip_ ⚠lookup_ new - Opens a maxminddb file by path.
- relay_
init - Initializes the library
- relay_
is_ ⚠codeowners_ path_ match - Returns
true
if the codeowners path matches the value,false
otherwise. - relay_
is_ ⚠glob_ match - Performs a glob operation on bytes.
- relay_
normalize_ ⚠global_ config - Normalize a global config.
- relay_
normalize_ ⚠project_ config - Normalize a project config.
- relay_
parse_ ⚠release - Parse a sentry release structure from a string.
- relay_
pii_ ⚠selector_ suggestions_ from_ event - Walk through the event and collect selectors that can be applied to it in a PII config. This function is used in the UI to provide auto-completion of selectors.
- relay_
pii_ ⚠strip_ event - Scrub an event using new PII stripping config.
- relay_
publickey_ ⚠free - Frees a public key.
- relay_
publickey_ ⚠parse - Parses a public key from a string.
- relay_
publickey_ ⚠to_ string - Converts a public key into a string.
- relay_
publickey_ ⚠verify - Verifies a signature
- relay_
publickey_ ⚠verify_ timestamp - Verifies a signature
- relay_
secretkey_ ⚠free - Frees a secret key.
- relay_
secretkey_ ⚠parse - Parses a secret key from a string.
- relay_
secretkey_ ⚠sign - Verifies a signature
- relay_
secretkey_ ⚠to_ string - Converts a secret key into a string.
- relay_
split_ ⚠chunks - Chunks the given text based on remarks.
- relay_
store_ ⚠normalizer_ free - Frees a
RelayStoreNormalizer
. - relay_
store_ ⚠normalizer_ new - Creates a new normalization config.
- relay_
store_ ⚠normalizer_ normalize_ event - Normalizes the event given as JSON.
- relay_
str_ ⚠free - Frees a Relay str.
- relay_
str_ ⚠from_ cstr - Creates a Relay string from a c string.
- relay_
test_ ⚠panic - A test function that always panics.
- relay_
translate_ ⚠legacy_ python_ json - Replaces invalid JSON generated by Python.
- relay_
uuid_ ⚠is_ nil - Returns true if the uuid is nil.
- relay_
uuid_ ⚠to_ str - Formats the UUID into a string.
- relay_
valid_ ⚠platforms - Returns a list of all valid platform identifiers.
- relay_
validate_ ⚠pii_ config - Validate a PII config against the schema. Used in project options UI.
- relay_
validate_ ⚠pii_ selector - Validates a PII selector spec. Used to validate datascrubbing safe fields.
- relay_
validate_ ⚠register_ response - Validates a register response.
- relay_
validate_ ⚠rule_ condition - Validate a dynamic rule condition.
- relay_
validate_ ⚠sampling_ configuration - Validate whole rule ( this will be also implemented in Sentry for better error messages) The implementation in relay is just to make sure that the Sentry implementation doesn’t go out of sync.
- relay_
version_ ⚠supported - Returns true if the given version is supported by this library.