### Install sentry-go SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/migration.mdx Use `go get` to install the `sentry-go` SDK. ```bash go get github.com/getsentry/sentry-go ``` -------------------------------- ### Install Raven-Go SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/legacy-sdk/index.mdx Use `go get` to install the `raven-go` library into your Go project. ```bash go get github.com/getsentry/raven-go ``` -------------------------------- ### Install Sentry FastHTTP SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/guides/fasthttp/index.mdx Install the Sentry Go SDK and the FastHTTP integration package using `go get`. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/fasthttp ``` -------------------------------- ### Install Sentry Go SDK for Echo Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/guides/echo/index.mdx Use `go get` to install the Sentry Go SDK and the `sentry-go/echo` integration package. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/echo ``` -------------------------------- ### Set Up OpenTelemetry Instrumentation in Application Start Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/elixir/tracing/index.mdx Call `setup()` functions for `OpentelemetryLoggerMetadata`, `OpentelemetryBandit`, `OpentelemetryPhoenix`, and `OpentelemetryEcto` within your application's `start/2` callback to instrument various components. ```elixir def start(_type, _args) do OpentelemetryLoggerMetadata.setup() OpentelemetryBandit.setup() OpentelemetryPhoenix.setup(adapter: :bandit) OpentelemetryEcto.setup([:my_app, :repo], db_statement: :enabled) children = [ # ... your supervision tree ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end ``` -------------------------------- ### Install and Start Self-Hosted Sentry with Bash Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/self-hosted/index.mdx Use this script to clone the latest self-hosted Sentry repository, check out the latest release, run the installation script, and then start the Sentry services using Docker Compose. ```bash VERSION=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/getsentry/self-hosted/releases/latest) VERSION=${VERSION##*/} git clone https://github.com/getsentry/self-hosted.git cd self-hosted git checkout ${VERSION} ./install.sh # After installation, run the following to start Sentry: docker compose up --wait ``` -------------------------------- ### Example SDK Interface Configuration (JSON) Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/sdk/foundations/envelopes/event-payloads/sdk.mdx This example demonstrates the structure of the `sdk` attribute within an event payload, showcasing how to define the SDK's name, version, enabled integrations, features, installed packages, and specific settings like IP inference. ```json { "sdk": { "name": "sentry.javascript.react-native", "version": "1.0.0", "integrations": ["redux"], "features": ["capture_failed_requests"], "packages": [ { "name": "npm:@sentry/react-native", "version": "0.39.0" }, { "name": "git:https://github.com/getsentry/sentry-cocoa.git", "version": "4.1.0" } ], "settings": { "infer_ip": "auto" } } } ``` -------------------------------- ### Start Profiler Function and Calls Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/sdk/telemetry/profiles/index.mdx Provides the generic function signature for starting the profiler, along with specific examples for JavaScript and Python SDKs. ```pseudocode startProfiler() -> void ``` ```javascript Sentry.startProfiler() ``` ```python sentry_sdk.start_profiler() ``` -------------------------------- ### Initialize Sentry in your project Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/sentry-init/install-command/_default.mdx Run this command in your project directory to start the interactive Sentry setup process, which configures Sentry and allows enabling optional features. ```bash npx sentry@latest init ``` -------------------------------- ### Install Sentry Go gRPC SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/guides/grpc/index.mdx Install the necessary Sentry Go SDK packages for gRPC integration using `go get`. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/grpc ``` -------------------------------- ### Run Demo Application via Makefile Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/sentry-basics/integrate-backend/getting-started.mdx Execute the 'deploy' target in the project's Makefile to install Python libraries, configure a Sentry Release, and start the Django server. ```bash make deploy ``` -------------------------------- ### Install Sentry Go Fiber SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/guides/fiber/index.mdx Use `go get` to add the Sentry Go SDK and the Fiber integration to your project dependencies. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/fiber ``` -------------------------------- ### Example Chartcuterie Service Startup Logs Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/services/chartcuterie.mdx Expected log output indicating the Chartcuterie service has successfully started and is ready to process render requests. ```text info: Using polling strategy to resolve configuration... info: Polling every 5s for config... info: Server listening for render requests on port 9090 info: Resolved new config via polling: n styles available. {"version":"xxx"} info: Config polling switching to idle mode info: Polling every 300s for config... ``` -------------------------------- ### Install Sentry Zerolog Go Package Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/logs/zerolog.mdx Use `go get` to add the Sentry Go SDK and the Zerolog integration package to your project dependencies. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/zerolog ``` -------------------------------- ### Install Sentry with the Remix Wizard Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/remix/index.mdx Run this command within your project to initiate the Sentry installation wizard for Remix, which guides you through the setup process and optional feature enablement. ```bash npx @sentry/wizard@latest -i remix ``` -------------------------------- ### Initialize and Start Development Servers Source: https://github.com/getsentry/sentry-docs/blob/master/CONTRIBUTING.md Use these commands to set up the project and start the development servers for user or developer documentation. ```bash make ``` ```bash pnpm dev ``` ```bash pnpm dev:developer-docs ``` -------------------------------- ### Implement the `afterAllSetup` Hook for Post-Initialization Logic Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/common/configuration/integrations/custom.mdx Demonstrates the `afterAllSetup` hook, which executes after all other integrations' `setupOnce()` and `setup()` hooks have completed, receiving the client instance. ```javascript const integration = { name: "MyAwesomeIntegration", afterAllSetup(client) { // We can be sure that all other integrations // have run their `setup` and `setupOnce` hooks now startSomeThing(client); } }; ``` -------------------------------- ### Install Sentry in Angular with Wizard Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/angular/index.mdx Run the Sentry wizard to automatically configure Sentry in your Angular application. It guides you through the setup process, asking to enable additional (optional) Sentry features. ```bash npx @sentry/wizard@latest -i angular ``` -------------------------------- ### GET /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ (Heartbeat - Failure) Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/monitors-and-alerts/monitors/crons/getting-started/http/index.mdx Sends a heartbeat to Sentry, indicating that a job has failed. This setup is primarily for basic monitoring where Sentry only notifies you if your job didn't start when expected (missed). ```APIDOC ## GET /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ ### Description Sends a heartbeat to Sentry, indicating that a job has failed. This setup is primarily for basic monitoring where Sentry only notifies you if your job didn't start when expected (missed). ### Method GET ### Endpoint /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ ### Parameters #### Path Parameters - **___PROJECT_ID___** (string) - Required - The ID of your Sentry project. - **** (string) - Required - The unique slug identifying your monitor. - **___PUBLIC_KEY___** (string) - Required - Your project's public DSN key. #### Query Parameters - **status** (string) - Required - The status of the job, specifically `error` for failure. ``` -------------------------------- ### Start the Frontend Application in Development Mode Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/sentry-basics/integrate-frontend/initialize-sentry-sdk.mdx Run this command to launch the sample application, which will typically be accessible via http://localhost:3000/. ```bash npm start ``` -------------------------------- ### GET /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ (Heartbeat - Success) Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/monitors-and-alerts/monitors/crons/getting-started/http/index.mdx Sends a heartbeat to Sentry, indicating that a job has completed successfully. This setup is primarily for basic monitoring where Sentry only notifies you if your job didn't start when expected (missed). ```APIDOC ## GET /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ ### Description Sends a heartbeat to Sentry, indicating that a job has completed successfully. This setup is primarily for basic monitoring where Sentry only notifies you if your job didn't start when expected (missed). ### Method GET ### Endpoint /api/___PROJECT_ID___/cron//___PUBLIC_KEY___/ ### Parameters #### Path Parameters - **___PROJECT_ID___** (string) - Required - The ID of your Sentry project. - **** (string) - Required - The unique slug identifying your monitor. - **___PUBLIC_KEY___** (string) - Required - Your project's public DSN key. #### Query Parameters - **status** (string) - Required - The status of the job, specifically `ok` for successful completion. ``` -------------------------------- ### Implement the `setupOnce` Hook for Single Execution Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/common/configuration/integrations/custom.mdx Illustrates the `setupOnce` hook, which runs only once even if the SDK is re-initialized. It does not receive any arguments. ```javascript const integration = { name: "MyAwesomeIntegration", setupOnce() { wrapLibrary(); } }; ``` -------------------------------- ### Implement the `setup` Hook in a Custom Integration Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/common/configuration/integrations/custom.mdx Shows how to use the `setup` hook to execute code when the Sentry SDK is initialized, receiving the client instance as an argument. ```javascript const integration = { name: "MyAwesomeIntegration", setup(client) { setupCustomSentryListener(client); } }; ``` -------------------------------- ### Mark Sentry App Installation as Verified (Python) Source: https://github.com/getsentry/sentry-docs/blob/master/docs/integrations/integration-platform/public-integration.mdx After completing installation setup on your end, send this PUT request to mark the Sentry app installation as officially 'installed'. ```python requests.put( u'https://sentry.io/api/0/sentry-app-installations/{}/'.format(install_id), json={'status': 'installed'}, ) ``` -------------------------------- ### Start Development Webserver Source: https://github.com/getsentry/sentry-docs/blob/master/docs/contributing/environment.mdx Starts the local development server, accessible at `http://localhost:3000`. Use `pnpm dev` for user docs or `pnpm dev:developer-docs` for developer docs. ```bash pnpm dev ``` ```bash pnpm dev:developer-docs ``` -------------------------------- ### Go Sentry Initialization with Conditional Performance Tracing Source: https://github.com/getsentry/sentry-docs/blob/master/docs/contributing/pages/components.mdx Provides a full Go application example demonstrating Sentry initialization. It includes product option markers to conditionally enable performance tracing based on user selection. ```go import ( "fmt" "net/http" "github.com/getsentry/sentry-go" sentrygin "github.com/getsentry/sentry-go/gin" "github.com/gin-gonic/gin" ) // To initialize Sentry's handler, you need to initialize Sentry itself beforehand if err := sentry.Init(sentry.ClientOptions{ Dsn: "___PUBLIC_DSN___", // _ __PRODUCT_OPTION_START___ performance EnableTracing: true, // Set TracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production, TracesSampleRate: 1.0, // _ __PRODUCT_OPTION_END___ performance // Adds request headers and IP for users, // visit: https://docs.sentry.io/platforms/go/data-management/data-collected/ for more info SendDefaultPII: true, }); err != nil { fmt.Printf("Sentry initialization failed: %v\n", err) } // Then create your app app := gin.Default() // Once it's done, you can attach the handler as one of your middleware app.Use(sentrygin.New(sentrygin.Options{})) // Set up routes app.GET("/", func(ctx *gin.Context) { ctx.String(http.StatusOK, "Hello world!") }) // And run it app.Run(":3000") ``` -------------------------------- ### Example Installation Webhook Payload Source: https://github.com/getsentry/sentry-docs/blob/master/docs/integrations/integration-platform/webhooks/installation.mdx This JSON payload demonstrates the structure of an installation webhook received by a public Sentry integration, detailing the action, actor, and installation data. ```json { "action": "created", "actor": { "id": 1, "name": "Meredith Heller", "type": "user" }, "data": { "installation": { "status": "pending", "organization": { "slug": "test-org" }, "app": { "uuid": "2ebf071f-28df-4989-aca9-c37c763b278f", "slug": "webhooks-galore" }, "code": "f3c71b491e3949b6b033ae45312a4fcb", "uuid": "a8e5d37a-696c-4c54-adb5-b3f28d64c7de" } }, "installation": { "uuid": "a8e5d37a-696c-4c54-adb5-b3f28d64c7de" } } ``` -------------------------------- ### Setting Up Development Environment for Debugging Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/development-infrastructure/devservices.mdx Initializes the development environment by bringing up services in `taskbroker` mode and starting the devserver. ```sh devservices up --mode taskbroker devservices serve ``` -------------------------------- ### CLI Commands for Project Setup and Checks Source: https://github.com/getsentry/sentry-docs/blob/master/AGENTS.md Various `make` and `pnpm` commands for initial project setup, running tests, and specific TypeScript, ESLint, and Prettier checks. ```bash make develop ``` ```bash make test ``` ```bash pnpm lint:ts ``` ```bash pnpm lint:eslint ``` ```bash pnpm lint:prettier ``` -------------------------------- ### Retrieve or Start a Transaction/Span Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/performance/retrieve-transaction/apple.mdx Use `SentrySDK.span` to get the current span or transaction. If no active span is found, start a new transaction; otherwise, start a child span from the retrieved span. ```Swift import Sentry var span = SentrySDK.span if span == nil { span = SentrySDK.startTransaction(name: "task", operation: "op") } else { span = span.startChild(operation: "subtask") } ``` ```Objective-C @import Sentry; id span = SentrySDK.span; if (span == nil) { span = [SentrySDK startTransactionWithName:@"task" operation:@"op"]; } else { span = [span startChildWithOperation: @"subtask"]; } ``` ```Objective-C (SentryObjC) #import SentryObjCSpan *span = SentryObjCSDK.span; if (span == nil) { span = [SentryObjCSDK startTransactionWithName:@"task" operation:@"op"]; } else { span = [span startChildWithOperation: @"subtask"]; } ``` -------------------------------- ### Implement the `setup` Hook in a Custom Sentry Integration Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/react-native/common/integrations/custom.mdx Shows how to use the `setup` hook to execute code when the Sentry SDK is initialized, receiving the client instance as an argument for SDK-specific operations. ```javascript const integration = { name: "MyAwesomeIntegration", setup(client) { setupCustomSentryListener(client); }, }; ``` -------------------------------- ### Complete Sentry File I/O tracing example Source: https://github.com/getsentry/sentry-docs/blob/master/includes/dart-integrations/file.mdx This example demonstrates initializing Sentry, wrapping a `File` with `sentryTrace()`, performing various file operations (create, write, read, delete), and finishing the transaction. ```dart import 'package:sentry/sentry.dart'; import 'package:sentry_file/sentry_file.dart'; import 'dart:io'; Future main() async { await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; // To set a uniform sample rate options.tracesSampleRate = 1.0; }, appRunner: runApp, // Init your App. ); } Future runApp() async { final file = File('my_file.txt'); // Call the Sentry extension method to wrap up the File final sentryFile = file.sentryTrace(); // Start a transaction if there's no active transaction final transaction = Sentry.startTransaction( 'MyFileExample', 'file', bindToScope: true, ); // create the File await sentryFile.create(); // Write some content await sentryFile.writeAsString('Hello World'); // Read the content final text = await sentryFile.readAsString(); print(text); // Delete the file await sentryFile.delete(); // Finish the transaction await transaction.finish(status: SpanStatus.ok()); await Sentry.close(); } ``` -------------------------------- ### Install Sentry Wizard for Flutter Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/dart/guides/flutter/index.mdx Use these commands to install the Sentry Wizard, which automates the setup of Sentry's Flutter SDK in your project. ```bash brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutter ``` ```powershell $downloadUrl = "https://github.com/getsentry/sentry-wizard/releases/download/v5.1.0/sentry-wizard-win-x64.exe" Invoke-WebRequest $downloadUrl -OutFile sentry-wizard.exe ./sentry-wizard.exe -i flutter ``` ```bash downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v5.1.0/sentry-wizard-darwin-x64" curl -L $downloadUrl -o sentry-wizard chmod +x sentry-wizard ./sentry-wizard -i flutter ``` ```bash downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v5.1.0/sentry-wizard-darwin-arm64" curl -L $downloadUrl -o sentry-wizard chmod +x sentry-wizard ./sentry-wizard -i flutter ``` ```bash downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v5.1.0/sentry-wizard-linux-x64" curl -L $downloadUrl -o sentry-wizard chmod +x sentry-wizard ./sentry-wizard -i flutter ``` ```bash downloadUrl="https://github.com/getsentry/sentry-wizard/releases/download/v5.1.0/sentry-wizard-linux-arm64" curl -L $downloadUrl -o sentry-wizard chmod +x sentry-wizard ./sentry-wizard -i flutter ``` ```bash npx @sentry/wizard@latest -i flutter ``` -------------------------------- ### Start Chartcuterie Development Service Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/services/chartcuterie.mdx Boot the Chartcuterie devservice. Verify 'chart-rendering.enabled' is 'true' if the service fails to start. ```shell devservices up --mode chartcuterie ``` -------------------------------- ### Install Sentry Go SQL Packages Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/tracing/instrumentation/sql.mdx Install the Sentry Go SDK and the `sentry-go/sql` package using `go get` to add them to your project dependencies. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/sql ``` -------------------------------- ### Integrate Sentry with Zerolog using an existing client Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/logs/zerolog.mdx This example demonstrates initializing Sentry with PII and debug options, then configuring Zerolog with a Sentry writer using `NewWithHub` to send specified error levels. It also shows logging different levels. ```go import ( "errors" "time" os" "github.com/getsentry/sentry-go" sentryzerolog "github.com/getsentry/sentry-go/zerolog" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) func main() { // Initialize Sentry err := sentry.Init(sentry.ClientOptions{ Dsn: "___PUBLIC_DSN___", // Adds request headers and IP for users, // visit: https://docs.sentry.io/platforms/go/data-management/data-collected/ for more info SendDefaultPII: true, BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { // Modify or filter events before sending them to Sentry return event }, Debug: true, AttachStacktrace: true, }) if err != nil { log.Fatal().Err(err).Msg("sentry initialization failed") } defer sentry.Flush(2 * time.Second) // Configure Zerolog to use Sentry as a writer, // reusing the already existing client. sentryWriter, err := sentryzerolog.NewWithHub(sentry.CurrentHub(), sentryzerolog.Options{ Levels: []zerolog.Level{zerolog.ErrorLevel, zerolog.FatalLevel, zerolog.PanicLevel}, WithBreadcrumbs: true, FlushTimeout: 3 * time.Second, }) if err != nil { log.Fatal().Err(err).Msg("failed to create sentry writer") } defer sentryWriter.Close() // Use Sentry writer in Zerolog log.Logger = log.Output(zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, sentryWriter)) // Log an InfoLevel entry to STDERR (not sent to Sentry) log.Info().Msg("Application has started") // Log an ErrorLevel entry to STDERR and send as error event to Sentry log.Error().Msg("oh no!") // Log a FatalLevel entry to STDERR, send as error event to Sentry, and terminate the application log.Fatal().Err(errors.New("can't continue")).Msg("fatal error occurred") } ``` -------------------------------- ### Install Sentry TanStack Start React SDK Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/tanstackstart-react/manual-setup/index.mdx Add the Sentry SDK package to your TanStack Start React application using your preferred package manager. ```bash npm install @sentry/tanstackstart-react --save ``` ```bash yarn add @sentry/tanstackstart-react ``` ```bash pnpm add @sentry/tanstackstart-react ``` -------------------------------- ### Practical Logging Examples with Sentry and Logback (Java/Kotlin) Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/java/guides/logback/usage/advanced-usage.mdx Demonstrates common logging patterns including simple error logging, adding breadcrumbs, attaching extra data via MDC, and capturing exceptions using Logback with Sentry. ```Java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; public class MyClass { private static final Logger logger = LoggerFactory.getLogger(MyClass.class); void logSimpleMessage() { // This sends a simple event to Sentry logger.error("This is a test"); } void logWithBreadcrumbs() { // Record a breadcrumb that will be sent with the next event(s), // by default the last 100 breadcrumbs are kept. Sentry.addBreadcrumb("User made an action"); // Log entries below `minimumEventLevel` and above or equal to `minimumBreadcrumbLevel` // are recorded as breadcrumbs logger.info("User made another action"); // This sends a simple event to Sentry logger.error("This is a test"); } void logWithExtras() { // MDC extras MDC.put("extra_key", "extra_value"); // This sends an event with extra data to Sentry logger.error("This is a test"); } void logException() { try { unsafeMethod(); } catch (Exception e) { // This sends an exception event to Sentry logger.error("Exception caught", e); } } void unsafeMethod() { throw new UnsupportedOperationException("You shouldn't call this!"); } } ``` ```Kotlin import io.sentry.core.Sentry import org.slf4j.LoggerFactory import org.slf4j.MDC class MyClass { companion object { private val logger = LoggerFactory.getLogger(Main::class.java) } fun logSimpleMessage() { // This sends a simple event to Sentry logger.error("This is a test") } fun logWithBreadcrumbs() { // Record a breadcrumb that will be sent with the next event(s), // by default the last 100 breadcrumbs are kept. Sentry.addBreadcrumb("User made an action") // Log entries below `minimumEventLevel` and above or equal to `minimumBreadcrumbLevel` // are recorded as breadcrumbs logger.info("User made another action") // This sends a simple event to Sentry logger.error("This is a test") } fun logWithExtras() { // MDC extras MDC.put("extra_key", "extra_value") // This sends an event with extra data to Sentry logger.error("This is a test") } fun logException() { try { unsafeMethod() } catch (e: Exception) { // This sends an exception event to Sentry logger.error("Exception caught", e) } } fun unsafeMethod() { throw UnsupportedOperationException("You shouldn't call this!") } } ``` -------------------------------- ### Install Sentry Logrus Integration Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/logs/logrus.mdx Install the Sentry Go SDK and the Logrus integration package using `go get` to enable Sentry's Logrus support. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/logrus ``` -------------------------------- ### Check for and Install Updates in SwiftUI Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/apple/guides/ios/build-distribution/auto-update.mdx This example demonstrates how to use Updater.checkForUpdate and Updater.install within a SwiftUI view to check for and install new builds. Remember to replace placeholder values for accessToken, organization, and project. ```swift import SentryDistribution import SwiftUI struct MyView: View { var body: some View { Button("Check For Update") { let params = CheckForUpdateParams( accessToken: "MY_TOKEN", organization: "___ORG_SLUG___", project: "___PROJECT_SLUG___") Updater.checkForUpdate(params: params) { result in handleUpdateResult(result: result) } } } static func handleUpdateResult(result: Result) { guard case let .success(releaseInfo) = result else { // Handle error return } guard let releaseInfo = releaseInfo.update else { print("Already up to date") return } guard let url = Updater.buildUrlForInstall(releaseInfo.downloadUrl) else { return } DispatchQueue.main.async { Updater.install(url: url) } } } ``` -------------------------------- ### Configure Zap Logger with Sentry Core Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/common/logs/zap.mdx This example demonstrates how to initialize the Sentry SDK, create a `sentryzap.Core` with specific log levels and caller information, and then use it to create a Zap logger that sends messages to Sentry. ```go package main import ( "context" "errors" "time" "github.com/getsentry/sentry-go" sentryzap "github.com/getsentry/sentry-go/zap" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) func main() { // Initialize Sentry (logs are enabled by default) err := sentry.Init(sentry.ClientOptions{ Dsn: "___PUBLIC_DSN___", }) if err != nil { panic(err) } defer sentry.Flush(2 * time.Second) // Create the Sentry core ctx := context.Background() sentryCore := sentryzap.NewSentryCore(ctx, sentryzap.Option{ Level: []zapcore.Level{ zapcore.InfoLevel, zapcore.WarnLevel, zapcore.ErrorLevel, }, AddCaller: true, }) // Create a zap logger with the Sentry core logger := zap.New(sentryCore) // Log messages will be sent to Sentry logger.Info("Application started", zap.String("version", "1.0.0"), zap.String("environment", "production"), ) logger.Warn("High memory usage", zap.Float64("usage_percent", 85.5), ) logger.Error("Database connection failed", zap.Error(errors.New("connection timeout")), zap.String("host", "db.example.com"), ) } ``` -------------------------------- ### Trigger a Test Error in Tanstack Start Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/cloudflare/frameworks/tanstack-start.mdx Add this button to any page in your Tanstack Start application to manually trigger a Sentry test error when clicked, verifying that your SDK setup is correctly capturing exceptions. ```tsx ``` -------------------------------- ### Install SDK Dependencies Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/sdk/getting-started/templates/contributing-md.mdx This placeholder indicates where to insert the specific command for installing project dependencies during the initial setup of an SDK development environment. Replace it with the actual command relevant to your SDK's ecosystem. ```shell [install command] ``` -------------------------------- ### Build and Serve Production Application Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/sentry-basics/integrate-frontend/configure-scms.mdx Create a production build of the application and serve it locally to verify changes and Sentry integration. ```bash npm run build ``` ```bash npx serve build ``` -------------------------------- ### Retrieve Current Transaction in Python Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/performance/retrieve-transaction/python.mdx Use `sentry_sdk.Hub.current.scope.transaction` to get the active transaction. If no transaction is found, a new one is started; otherwise, the existing transaction's name is updated, and a child span is started. ```python import sentry_sdk transaction = sentry_sdk.Hub.current.scope.transaction if transaction is None: with sentry_sdk.start_transaction(name="task"): do_task() else: transaction.name = "new name" with transaction.start_child(op="task"): # equivalent to `sentry_sdk.start_span` do_task() ``` -------------------------------- ### Start Ngrok HTTP Tunnel for Local Sentry Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/sdk/platform-specifics/serverless-sdks/aws-lambda-development-environment.mdx Starts Ngrok to expose local port 8000, making your Sentry installation accessible via a public URL. Copy the HTTP URL provided by Ngrok. ```bash ngrok http 8000 ``` -------------------------------- ### Install Sentry Go SDK and Gin Integration Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/go/guides/gin/index.mdx Use these commands to install the Sentry Go SDK and the Gin-specific integration package. ```bash go get github.com/getsentry/sentry-go go get github.com/getsentry/sentry-go/gin ``` -------------------------------- ### Start the GitHub SCM RPC Server Locally Source: https://github.com/getsentry/sentry-docs/blob/master/develop-docs/backend/source-code-management-platform.mdx Start the local GitHub RPC server. Ensure .credentials is populated with GitHub App details, or provide them inline as command-line arguments. ```bash # Populate .credentials with your GitHub App credentials (KEY=VALUE, one per line): # GITHUB_APP_ID= # GITHUB_PRIVATE_KEY_PATH= # GITHUB_INSTALLATION_ID= # SCM_RPC_SIGNING_SECRET=secret bin/github-server # or override inline: bin/github-server --app-id 12345 --private-key key.pem --installation-id 67890 --port 8080 ``` -------------------------------- ### Install Sentry AWS Serverless SDK for Error Monitoring Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/aws-lambda/install/npm.mdx Installs the core Sentry AWS Serverless SDK for basic error monitoring in AWS Lambda functions. Use this for minimal setup without performance or profiling features. ```bash npm install @sentry/aws-serverless ``` ```bash yarn add @sentry/aws-serverless ``` ```bash pnpm add @sentry/aws-serverless ``` -------------------------------- ### Starting Child Spans from Automatic Transactions in ASP.NET Core Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/dotnet/guides/aspnetcore/tracing/instrumentation/automatic-instrumentation.mdx This example demonstrates how to start custom child spans from an automatically created transaction using `_sentryHub.GetSpan()?.StartChild()`. This allows for measuring specific operations within an automatically traced HTTP request. ```csharp using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; public class HomeController : Controller { private readonly IHub _sentryHub; public HomeController(IHub sentryHub) => _sentryHub = sentryHub; [HttpGet("/person/{id}")] public IActionResult Person(string id) { var childSpan = _sentryHub.GetSpan()?.StartChild("additional-work"); try { // Do the work that gets measured. childSpan?.Finish(SpanStatus.Ok); } catch (Exception e) { childSpan?.Finish(SpanStatus.InternalError); throw; } } } ``` -------------------------------- ### Clone the Frontend Sample Application Source: https://github.com/getsentry/sentry-docs/blob/master/docs/product/sentry-basics/distributed-tracing/initialize-sentry-sdk-frontend.mdx Use this command to clone the forked sample application repository to your local environment. ```bash git clone git@github.com:/tracing-tutorial-frontend.git ``` -------------------------------- ### Add a Tag Filter to Sentry Options Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/dotnet/guides/extensions-logging/index.mdx This example demonstrates how to add a tag filter to `SentryOptions` to exclude specific tags, such as those starting with 'PROC_'. ```csharp options.TagFilters.Add("PROC_"); ``` -------------------------------- ### Enable ReportingObserver Integration with Sentry Loader (v7) Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/configuration/enable-pluggable-integrations/javascript.mdx This example shows how to configure `sentryOnLoad` to add the `reportingObserverIntegration` for Sentry Loader v7 setups. ```html ``` -------------------------------- ### Example Source Bundle Directory Structure Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/source-context/java.mdx Illustrates the typical directory structure of a multi-module Java source bundle after unzipping, showing how package paths are preserved. ```text bundle/ └── files └── _ └── ~ └── io └── sentry └── android ├── core │ ├── ANRWatchDog.jvm │ ├── ActivityLifecycleIntegration.jvm │ ├── AppLifecycleIntegration.jvm │ └── ... ├── distribution │ ├── DistributionHttpClient.jvm │ ├── DistributionIntegration.jvm │ └── UpdateResponseParser.jvm ├── fragment │ ├── FragmentLifecycleIntegration.jvm │ ├── FragmentLifecycleState.jvm │ └── SentryFragmentLifecycleCallbacks.jvm ├── navigation │ └── SentryNavigationListener.jvm └── ... ``` -------------------------------- ### Install Sentry Wizard for Next.js Source: https://github.com/getsentry/sentry-docs/blob/master/docs/platforms/javascript/guides/nextjs/index.mdx Execute this command to automatically configure Sentry in your Next.js application. The wizard will guide you through selecting desired features. ```bash npx @sentry/wizard@latest -i nextjs ``` -------------------------------- ### Initialize Sentry SDK Source: https://github.com/getsentry/sentry-docs/blob/master/platform-includes/performance/opentelemetry-setup/without-java-agent/java.mdx Set up the Sentry SDK with your DSN and configure trace sampling for performance monitoring. ```java import io.sentry.Sentry; Sentry.init(options -> { options.setDsn("___PUBLIC_DSN___"); options.setTracesSampleRate(1.0); }); ``` ```kotlin import io.sentry.Sentry Sentry.init { options -> options.dsn = "___PUBLIC_DSN___" options.tracesSampleRate = 1.0 } ```