import {Fragment} from 'react'; import styled from '@emotion/styled'; import {Alert} from 'sentry/components/alert'; import ExternalLink from 'sentry/components/links/externalLink'; import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout'; import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation'; import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; import {t, tct} from 'sentry/locale'; // Configuration Start export const steps = ({ dsn, }: { dsn?: string; } = {}): LayoutProps['steps'] => [ { type: StepType.INSTALL, description: (
{tct('Install our Go Negroni SDK using [code:go get]:', {
code: ,
})}
{tct(
'[sentryNegroniCode:sentrynegroni] accepts a struct of [optionsCode:Options] that allows you to configure how the handler will behave.',
{sentryNegroniCode: , optionsCode:
}
)}
{tct(
"[sentryNegroniCode:sentrynegroni] attaches an instance of [sentryHubLink:*sentry.Hub] to the request's context, which makes it available throughout the rest of the request's lifetime. You can access it by using the [getHubFromContextCode:sentry.GetHubFromContext()] method on the request itself in any of your proceeding middleware and routes. And it should be used instead of the global [captureMessageCode:sentry.CaptureMessage], [captureExceptionCode:sentry.CaptureException], or any other calls, as it keeps the separation of data between the requests.",
{
sentryNegroniCode: ,
sentryHubLink: (
,
captureMessageCode:
,
captureExceptionCode:
,
}
)}
, sentryHubCode:
}
)}
,
})}
),
language: 'go',
code: `
sentry.Init(sentry.ClientOptions{
Dsn: "${dsn}",
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
if hint.Context != nil {
if req, ok := hint.Context.Value(sentry.RequestContextKey).(*http.Request); ok {
// You have access to the original Request here
}
}
return event
},
})
`,
},
],
},
{
title: t("Using Negroni's 'panicHandlerFuncCode' Option"),
description: (
{tct(
"Negroni provides an option called [panicHandlerFuncCode:PanicHandlerFunc], which lets you 'plug-in' to its default [recoveryCode:Recovery] middleware.",
{
panicHandlerFuncCode: ,
recoveryCode:
,
}
)}
{tct(
"[sentrynegroniCode:sentrynegroni] exports a very barebones implementation, which utilizes it, so if you don't need anything else than just reporting panics to Sentry, you can use it instead, as it's just one line of code!",
{
sentrynegroniCode: ,
}
)}
{tct(
'You can still use [beforeSendCode:BeforeSend] and event processors to modify data before delivering it to Sentry, using this method as well.',
{
beforeSendCode: ,
}
)}