Skip to content

Commit

Permalink
[pull] master from getsentry:master (#14)
Browse files Browse the repository at this point in the history
* ci(codechecker): Workaround for code checker not building due to node issues (getsentry#615)

* meta: Update breakpad/crashpad to 2021-12-03 (getsentry#614)

* feat(tracing): Add config options (getsentry#613)

* fix: Correct changelog entry (getsentry#622)

* meta: Bump breakpad (getsentry#621)

* feat: Add internal UUID types (getsentry#616)

This adds in support for internal UUIDs needed by tracing,
such as the trace ID and the span ID.
 
The major difference between this and the "standard" UUID 
is that the hyphens are stripped during serialization. sentry 
appears to not consider the hyphenated representations of 
these UUIDs to be valid for certain fields in an event.

* meta: Update changelog (getsentry#625)

* release: 0.4.13

* feat(tracing): Groundwork to add tracing context to all events (getsentry#617)

This adds the appropriate stubs and fields to 
start storing spans on the (universal) scope. 
No actual logic has been added to actually 
support setting spans on the scope itself.

The focus of this is to begin including tracing 
info in the context on all events if there is a 
transaction set on the scope. It does this fairly 
naively right now as the tooling to merge 
`sentry_value_t`s are basically nonexistent.

* ci: Make integration tests capable of reading the non-backwards compatible version number for Big Sur (getsentry#627)

* feat(tracing): Basic transaction context creation (getsentry#619)

This adds in the ability to create and manipulate transaction contexts as defined in 
https://develop.sentry.dev/sdk/performance/#new-span-and-transaction-classes, 
under Transaction Interface.

Instead of defining several transaction constructor functions with varying names 
(since overloading doesn't exist), the decision has been made to have the user 
construct an "inactive" transaction which should be fed into the SDK's 
implementation of `start_transaction`. This follows an existing pattern in the SDK 
where exceptions, threads, messages, etc can be constructed but they must be 
explicitly added to an event to be sent to sentry.

* feat(tracing): Support basic sampling of transactions (getsentry#620)

If an event is a transaction, event flushing should determine 
discard or forward the transaction to sentry based on the
sample rate as configured in sentry options. Follows the 
sampling rules as defined in 
https://develop.sentry.dev/sdk/performance/#sampling-context.

This does not take into consideration parent sampling as 
that property is currently unimplemented on the transaction 
context.

* feat(tracing): Introduce a helper that identifies events that are transactions (getsentry#628)

* feat(tracing): Restrict `sentry_capture_event` so it only sends non-transaction events (getsentry#629)

Prevent the public API from being used to send transaction events
as another transaction-specific function is meant to be used to 
accomplish this.

* fix: Avoid deadlocks with uninitialized options (getsentry#639)

The `SENTRY_WITH_OPTIONS_MUT` was a footgun since it never unlocked when
the options were NULL (uninitialized).
This removes the macro and replaces its uses with explicit lock/unlock calls.

* feat(tracing): Add in basic Envelope support for Transactions (getsentry#630)

* feat(tracing): Allow manual creation and sending of spanless Transactions (getsentry#631)

* feat(tracing): Defer some transaction validation and allow creation of internal spans (getsentry#633)

Co-authored-by: relaxolotl <5597345+relaxolotl@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: getsentry-bot <bot@sentry.io>
Co-authored-by: Arpad Borsos <swatinem@swatinem.de>
Co-authored-by: Arpad Borsos <arpad.borsos@sentry.io>
  • Loading branch information
6 people authored Dec 24, 2021
1 parent 0e17d7c commit f86afdd
Show file tree
Hide file tree
Showing 36 changed files with 1,175 additions and 53 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ jobs:
- name: macOS (xcode llvm)
os: macOs-latest
ERROR_ON_WARNINGS: 1
SYSTEM_VERSION_COMPAT: 0
- name: macOS (xcode llvm + universal)
os: macOs-latest
ERROR_ON_WARNINGS: 1
SYSTEM_VERSION_COMPAT: 0
CMAKE_DEFINES: -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64
- name: macOS (clang 11 + asan + llvm-cov)
os: macOs-latest
CC: clang
CXX: clang++
ERROR_ON_WARNINGS: 1
SYSTEM_VERSION_COMPAT: 0
RUN_ANALYZER: asan,llvm-cov
- name: Windows (VS2017, 32bit)
os: vs2017-win2016
Expand Down Expand Up @@ -98,6 +101,7 @@ jobs:
ANDROID_API: ${{ matrix.ANDROID_API }}
ANDROID_NDK: ${{ matrix.ANDROID_NDK }}
CMAKE_DEFINES: ${{ matrix.CMAKE_DEFINES }}
SYSTEM_VERSION_COMPAT: ${{ matrix.SYSTEM_VERSION_COMPAT }}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -127,7 +131,7 @@ jobs:
sudo apt install clang-tidy curl doxygen gcc-multilib libxml2-dev libxslt1-dev python3-dev python3-virtualenv
git clone https://github.com/Ericsson/CodeChecker.git --depth 1 --branch v6.15.0
cd CodeChecker
BUILD_LOGGER_64_BIT_ONLY=YES make standalone_package
BUILD_LOGGER_64_BIT_ONLY=YES BUILD_UI_DIST=NO make standalone_package
echo "$PWD/build/CodeChecker/bin" >> $GITHUB_PATH
- name: Expose llvm PATH for Mac
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 0.4.13

**Features**

- Add client-side stackwalking on Linux, Windows, and macOS (disabled by default).
- CMake: add ability to set solution folder name.
- Add AIX support.

**Fixes**

- CMake: check whether libcurl was already found.
- Increment CXX standard version to 14 to allow crashpad to build.

**Internal**:

- Update Crashpad and Breakpad submodules to 2021-12-03.

**Thank you**:

Features, fixes and improvements in this release have been contributed by:

- [@Mixaill](https://github.com/Mixaill)
- [@ladislavmacoun](https://github.com/ladislavmacoun)
- [@NattyNarwhal](https://github.com/NattyNarwhal)
- [@mjvankampen](https://github.com/mjvankampen)

## 0.4.12

**Features**:
Expand Down
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ be done manually.

Creates a python virtualenv, and runs all the tests through `pytest`.

**Running integration-tests manually**:
**Running integration tests manually**:

$ pytest --verbose --maxfail=1 --capture=no tests/

Expand All @@ -47,13 +47,20 @@ can also be invoked directly.
The `maxfail` parameter will abort after the first failure, and `capture=no`
will print the complete compiler output, and test log.

**Running unit-tests manually**:
**Running unit tests**:

$ make test-unit

Unit tests also have a dedicated `make` target, if they need to be run separately
from the integration tests.

**Running unit tests manually**:

$ cmake -B build -D CMAKE_RUNTIME_OUTPUT_DIRECTORY=$(pwd)/build
$ cmake --build build --target sentry_test_unit
$ ./build/sentry_test_unit

The unit-tests are a separate executable target and can be built and run on
The unit tests are a separate executable target and can be built and run on
their own.

## How to interpret CI failures
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ build/sentry_test_unit: build
test: update-test-discovery test-integration
.PHONY: test

test-unit: update-test-discovery build/sentry_test_unit
./build/sentry_test_unit
.PHONY: test-unit

test-integration: setup-venv
.venv/bin/pytest tests --verbose
.PHONY: test-integration
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The SDK supports different features on the target platform:
have the `curl` library available. On other platforms, library users need to
implement their own transport, based on the `function transport` API.
- **Crashpad Backend** is currently only supported on Linux, Windows and macOS.
- **Client-side stackwalking** is currently only supported on Linux, Windows, and macOS.

## Building and Installation

Expand Down Expand Up @@ -265,6 +266,11 @@ Legend:
Sets the sentry-native projects folder name for generators which support project hierarchy (like Microsoft Visual Studio).
To use this feature you need to enable hierarchy via [`USE_FOLDERS` property](https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html)

- `CRASHPAD_ENABLE_STACKTRACE` (Default: OFF):
This enables client-side stackwalking when using the crashpad backend. Stack unwinding will happen on the client's machine
and the result will be submitted to Sentry attached to the generated minidump.
Note that this feature is still experimental.

### Build Targets

- `sentry`: This is the main library and the only default build target.
Expand Down
17 changes: 17 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ main(int argc, char **argv)
options, sentry_transport_new(print_envelope));
}

if (has_arg(argc, argv, "capture-transaction")) {
sentry_options_set_traces_sample_rate(options, 1.0);
}

sentry_init(options);

if (!has_arg(argc, argv, "no-setup")) {
Expand Down Expand Up @@ -208,6 +212,19 @@ main(int argc, char **argv)
sentry_capture_event(event);
}

if (has_arg(argc, argv, "capture-transaction")) {
sentry_value_t tx_ctx
= sentry_value_new_transaction_context("I'm a little teapot",
"Short and stout here is my handle and here is my spout");

if (has_arg(argc, argv, "unsample-tx")) {
sentry_transaction_context_set_sampled(tx_ctx, 0);
}

sentry_value_t tx = sentry_transaction_start(tx_ctx);
sentry_transaction_finish(tx);
}

// make sure everything flushes
sentry_close();

Expand Down
2 changes: 1 addition & 1 deletion external/breakpad
Submodule breakpad updated 76 files
+0 −17 .github/mistaken-pull-closer.yml
+73 −0 .github/workflows/build-test-ci.yml
+22 −0 .github/workflows/close-pull-request.yml
+44 −0 .github/workflows/coverity.yml
+0 −34 .travis.yml
+1 −1 DEPS
+13 −0 DIR_METADATA
+6 −6 Makefile.am
+8 −8 Makefile.in
+1 −1 README.md
+20 −20 configure
+11 −11 configure.ac
+1 −1 default.xml
+0 −70 scripts/travis-build.sh
+0 −24 scripts/travis-checkout.sh
+8 −0 src/client/ios/Breakpad.xcodeproj/project.pbxproj
+1 −1 src/client/linux/handler/exception_handler.cc
+6 −5 src/client/mac/Framework/OnDemandServer.mm
+6 −3 src/common/dwarf/dwarf2diehandler.h
+1 −1 src/common/dwarf/dwarf2reader.cc
+291 −132 src/common/dwarf_cu_to_module.cc
+10 −2 src/common/dwarf_cu_to_module.h
+13 −11 src/common/dwarf_cu_to_module_unittest.cc
+2 −2 src/common/dwarf_line_to_module.cc
+8 −5 src/common/dwarf_line_to_module.h
+38 −19 src/common/dwarf_line_to_module_unittest.cc
+8 −7 src/common/language.cc
+66 −0 src/common/linux/breakpad_getcontext.S
+10 −5 src/common/linux/dump_symbols.cc
+6 −1 src/common/mac/arch_utilities.cc
+10 −6 src/common/mac/dump_syms.cc
+123 −3 src/common/module.cc
+106 −3 src/common/module.h
+2 −1 src/common/module_unittest.cc
+2 −1 src/common/stabs_to_module.cc
+3 −3 src/common/stabs_to_module_unittest.cc
+114 −0 src/common/string_view.h
+2 −2 src/common/windows/http_upload.cc
+80 −35 src/google_breakpad/common/minidump_exception_linux.h
+3 −1 src/google_breakpad/common/minidump_exception_mac.h
+17 −10 src/google_breakpad/processor/basic_source_line_resolver.h
+2 −0 src/google_breakpad/processor/fast_source_line_resolver.h
+2 −1 src/google_breakpad/processor/source_line_resolver_base.h
+2 −1 src/google_breakpad/processor/source_line_resolver_interface.h
+2 −1 src/google_breakpad/processor/stack_frame_symbolizer.h
+142 −72 src/processor/basic_source_line_resolver.cc
+19 −19 src/processor/basic_source_line_resolver_types.h
+136 −38 src/processor/basic_source_line_resolver_unittest.cc
+23 −5 src/processor/contained_range_map-inl.h
+23 −5 src/processor/contained_range_map.h
+152 −35 src/processor/contained_range_map_unittest.cc
+0 −4 src/processor/exploitability_linux.cc
+0 −1 src/processor/exploitability_win.cc
+70 −5 src/processor/fast_source_line_resolver.cc
+80 −18 src/processor/fast_source_line_resolver_types.h
+102 −0 src/processor/fast_source_line_resolver_unittest.cc
+38 −34 src/processor/minidump.cc
+3 −0 src/processor/minidump_processor.cc
+23 −0 src/processor/minidump_processor_unittest.cc
+12 −4 src/processor/module_serializer.cc
+2 −0 src/processor/module_serializer.h
+111 −2 src/processor/simple_serializer-inl.h
+1 −1 src/processor/source_line_resolver_base.cc
+22 −15 src/processor/source_line_resolver_base_types.h
+1 −1 src/processor/stack_frame_symbolizer.cc
+1 −1 src/processor/stackwalk_common.cc
+5 −4 src/processor/stackwalker.cc
+17 −0 src/processor/static_contained_range_map-inl.h
+6 −0 src/processor/static_contained_range_map.h
+19 −0 src/processor/static_contained_range_map_unittest.cc
+71 −0 src/processor/testdata/symbols/linux_inline/BBA6FA10B8AAB33D00000000000000000/linux_inline.new.sym
+0 −0 src/processor/testdata/symbols/linux_inline/BBA6FA10B8AAB33D00000000000000000/linux_inline.old.sym
+ src/processor/testdata/tiny-exe-with-cet-xsave.dmp
+6 −2 src/tools/linux/dump_syms/dump_syms.cc
+2 −3 src/tools/linux/md2core/minidump-2-core.cc
+9 −3 src/tools/mac/dump_syms/dump_syms_tool.cc
2 changes: 1 addition & 1 deletion external/crashpad
Submodule crashpad updated 488 files
126 changes: 120 additions & 6 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

/* SDK Version */
#define SENTRY_SDK_NAME "sentry.native"
#define SENTRY_SDK_VERSION "0.4.12"
#define SENTRY_SDK_VERSION "0.4.13"
#define SENTRY_SDK_USER_AGENT SENTRY_SDK_NAME "/" SENTRY_SDK_VERSION

/* common platform detection */
Expand Down Expand Up @@ -193,7 +193,7 @@ SENTRY_API sentry_value_t sentry_value_new_int32(int32_t value);
SENTRY_API sentry_value_t sentry_value_new_double(double value);

/**
* Creates a new boolen value.
* Creates a new boolean value.
*/
SENTRY_API sentry_value_t sentry_value_new_bool(int value);

Expand Down Expand Up @@ -554,13 +554,21 @@ typedef struct sentry_envelope_s sentry_envelope_t;
SENTRY_API void sentry_envelope_free(sentry_envelope_t *envelope);

/**
* Given an envelope returns the embedded event if there is one.
* Given an Envelope, returns the embedded Event if there is one.
*
* This returns a borrowed value to the event in the envelope.
* This returns a borrowed value to the Event in the Envelope.
*/
SENTRY_API sentry_value_t sentry_envelope_get_event(
const sentry_envelope_t *envelope);

/**
* Given an Envelope, returns the embedded Transaction if there is one.
*
* This returns a borrowed value to the Transaction in the Envelope.
*/
SENTRY_EXPERIMENTAL_API sentry_value_t sentry_envelope_get_transaction(
const sentry_envelope_t *envelope);

/**
* Serializes the envelope.
*
Expand All @@ -582,7 +590,7 @@ SENTRY_API int sentry_envelope_write_to_file(
/**
* The Sentry Client Options.
*
* See https://docs.sentry.io/error-reporting/configuration/
* See https://docs.sentry.io/platforms/native/configuration/
*/
struct sentry_options_s;
typedef struct sentry_options_s sentry_options_t;
Expand Down Expand Up @@ -1103,7 +1111,8 @@ SENTRY_API void sentry_user_consent_reset(void);
SENTRY_API sentry_user_consent_t sentry_user_consent_get(void);

/**
* Sends a sentry event.
* Sends a sentry event. Returns a nil UUID if the event being passed in is a
* transaction; `sentry_transaction_finish` should be used to send transactions.
*/
SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event);

Expand Down Expand Up @@ -1198,6 +1207,111 @@ SENTRY_API void sentry_start_session(void);
*/
SENTRY_API void sentry_end_session(void);

/**
* Sets the maximum number of spans that can be attached to a
* transaction.
*/
SENTRY_EXPERIMENTAL_API void sentry_options_set_max_spans(
sentry_options_t *opts, size_t max_spans);

/**
* Gets the maximum number of spans that can be attached to a
* transaction.
*/
SENTRY_EXPERIMENTAL_API size_t sentry_options_get_max_spans(
sentry_options_t *opts);

/**
* Sets the sample rate for transactions. Should be a double between
* `0.0` and `1.0`. Transactions will be randomly discarded during
* `sentry_transaction_finish` when the sample rate is < 1.0.
*/
SENTRY_EXPERIMENTAL_API void sentry_options_set_traces_sample_rate(
sentry_options_t *opts, double sample_rate);

/**
* Returns the sample rate for transactions.
*/
SENTRY_EXPERIMENTAL_API double sentry_options_get_traces_sample_rate(
sentry_options_t *opts);

/* -- Performance Monitoring/Tracing APIs -- */

/**
* Constructs a new Transaction Context. The returned value needs to be passed
* into `sentry_transaction_start` in order to be recorded and sent to sentry.
*
* See
* https://docs.sentry.io/platforms/native/enriching-events/transaction-name/
* for an explanation of a Transaction's `name`, and
* https://develop.sentry.dev/sdk/performance/span-operations/ for conventions
* around an `operation`'s value.
*
* Also see https://develop.sentry.dev/sdk/event-payloads/transaction/#anatomy
* for an explanation of `operation`, in addition to other properties and
* actions that can be performed on a Transaction.
*/
SENTRY_EXPERIMENTAL_API sentry_value_t sentry_value_new_transaction_context(
const char *name, const char *operation);

/**
* Sets the `name` on a Transaction Context, which will be used in the
* Transaction constructed off of the context.
*/
SENTRY_EXPERIMENTAL_API void sentry_transaction_context_set_name(
sentry_value_t transaction, const char *name);

/**
* Sets the `operation` on a Transaction Context, which will be used in the
* Transaction constructed off of the context
*
* See https://develop.sentry.dev/sdk/performance/span-operations/ for
* conventions on `operation`s.
*/
SENTRY_EXPERIMENTAL_API void sentry_transaction_context_set_operation(
sentry_value_t transaction, const char *operation);

/**
* Sets the `sampled` field on a Transaction Context, which will be used in the
* Transaction constructed off of the context.
*
* When passed any value above 0, the Transaction will bypass all sampling
* options and always be sent to sentry. If passed 0, this Transaction and its
* child spans will never be sent to sentry.
*/
SENTRY_EXPERIMENTAL_API void sentry_transaction_context_set_sampled(
sentry_value_t transaction, int sampled);

/**
* Removes the sampled field on a Transaction Context, which will be used in the
* Transaction constructed off of the context.
*
* The Transaction will use the sampling rate as defined in `sentry_options`.
*/
SENTRY_EXPERIMENTAL_API void sentry_transaction_context_remove_sampled(
sentry_value_t transaction);

/**
* Starts a new Transaction based on the provided context, restored from an
* external integration (i.e. a span from a different SDK) or manually
* constructed by a user.
*
* Takes ownership of `transaction_context`.
*/
SENTRY_EXPERIMENTAL_API sentry_value_t sentry_transaction_start(
sentry_value_t transaction_context);

/**
* Finishes and sends a transaction to sentry. The event ID of the transaction
* will be returned if this was successful; A nil UUID will be returned
* otherwise.
*
* Always takes ownership of `transaction`, regardless of whether the operation
* was successful or not.
*/
SENTRY_EXPERIMENTAL_API sentry_uuid_t sentry_transaction_finish(
sentry_value_t transaction);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ sentry_target_sources_cwd(sentry
sentry_symbolizer.h
sentry_sync.c
sentry_sync.h
sentry_tracing.c
sentry_tracing.h
sentry_transport.c
sentry_transport.h
sentry_utils.c
Expand Down
2 changes: 2 additions & 0 deletions src/backends/sentry_backend_inproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ handle_ucontext(const sentry_ucontext_t *uctx)

sentry_envelope_t *envelope
= sentry__prepare_event(options, event, NULL);
// TODO(tracing): Revisit when investigating transaction flushing during
// hard crashes.

sentry_session_t *session = sentry__end_current_session_with_status(
SENTRY_SESSION_STATUS_CRASHED);
Expand Down
Loading

0 comments on commit f86afdd

Please sign in to comment.