Puzzle Tech Kafi, 29.05.2019
Mathis Hofer & Thomas Philipona
Bugs fixen bevor die User sich melden
Logging
Metrics
Tracing
While there are many good tools that make development easier, the post-deployment process of discovery, investigation, and remediation is still painful, confusing, annoying, and lengthy.
— Adhiraj Somani, Sentry
EST. 21. März 2019
sentry.puzzle.ch wurde vom Techboard eingerichtet
Erste Projekte verwenden Sentry
(Acrevis, B4U, Marina, PuzzleTime, socialweb, Zeus etc.)
Erfahrungen sammeln
Best Practices erarbeiten
Ablösung von Errbit bei allen Ruby Projekten bis Ende Jahr
Für Java Projekte und im Frontend als Standard etablieren
Und: Gewünschte Teams joinen, damit die Projekte sichtbar werden
Es gibt eine Organization: pitc
Pro Projekt ein Team erstellen mit Projektkürzel:
z.B. pofi-b4u
Im Team pro (Micro-)Service ein Project erstellen:
z.B. b4u-backend, b4u-frontend
Umgebungen (Integration, Produktion etc.) als Environment im gleichen Project abbilden:
environment im SDK konfigurieren
JavaScript, Browser JavaScript CDN, Java, Node.js, .NET, PHP, Ruby, Vue, Angular, Ember, React, React Native, Cordova, Electron, Python, Django, Flask, Sanic, Celery, AWS Lambda (Python), Serverless (Python), Pyramid, RQ (Redis Queue), WSGI, AIOHTTP, Tornado, Bottle, Rust, actix-web, Minidump, Elixir, Cocoa, Go
Sentry-supported:
Community-supported:
C++, Clojure, Crystal, Dart, Grails, Kubernetes, Lua, Nuxt, OCaml, Scrapy, Terraform, Wordpress, Zend
0 Issues
Irrelevante Fehler in Applikation handeln
Organisatorisch: Wochenverantwortung
Exception, Stack Trace
Umgebung, Version
Request URL, Parameter, Headers
Benutzer, Browser, Betriebssystem
Auf einen Blick:
Wie häufig tritt der Fehler auf?
Erstes Ereignis, letztes Ereignis
Fehler werden per E-Mail notifiziert
(kann auch global deaktiviert werden)
Häufigkeit kann pro Projekt/Umgebung konfiguriert werden:
Mit SDK den release konfigurieren
(z.B. Commit Hash oder Versionsnummer)
Manche SDKs unterstützen automatisches Guessing
Issues werden einem Release zugeordnet (getagged):
Release erstellen:
entweder implizit (durch Issue)
oder explizit (via CLI/API/Webhook)
Weitere Funktionen:
Artefakte (Sourcen/Sourcemaps) anhängen
Verknüpfung mit Commit → Gitlab/Github Plugin konfigurieren
compile 'io.sentry:sentry-spring:1.7.16'
@Bean
public HandlerExceptionResolver sentryExceptionResolver() {
return new io.sentry.spring.SentryExceptionResolver();
}
@Bean
public ServletContextInitializer sentryServletContextInitializer() {
return new io.sentry.spring.SentryServletContextInitializer();
}
Konfiguration in Initializers:
gem "sentry-raven"Rails.application.config.filter_parameters += [:password, :token]
Raven.configure do |config|
config.sanitize_fields =
Rails.application.config.filter_parameters.map(&:to_s)
config.release = ENV['OPENSHIFT_BUILD_COMMIT']
endEnvironment als SENTRY_CURRENT_ENV setzen
class ApplicationController < ActionController::API
before_action :set_sentry_request_context
before_action :set_sentry_user_context
private
def set_sentry_request_context
Raven.extra_context(
params: params.to_unsafe_h,
url: request.url
)
end
def set_sentry_user_context
Raven.user_context(
id: current_user.try(:id),
name: current_user.try(:username)
)
end
endclass ApplicationJob < ActiveJob::Base
rescue_from(Exception) do |e|
Raven.capture_exception(e, logger: 'delayed_job')
end
def deserialize(job_data)
super(job_data)
Raven.extra_context(active_job: job_data)
end
end(bietet neue unified API, raven-js ist veraltet)
Konfiguration:
npm install @sentry/browserimport * as Sentry from '@sentry/browser';
Sentry.init({
dsn: 'https://<key>@sentry.io/<project>'
environment: 'integration',
release: '1.23'
});Erfasst automatisch global alle Exceptions
SourceMaps:
Bei Angular ErrorHandler implementieren:
@Injectable()
export class SentryErrorHandler implements ErrorHandler {
constructor() {
Sentry.init({
dsn: 'https://<key>@sentry.puzzle.ch/<project>',
environment: 'integration',
release: '1.23'
});
}
handleError(error: any) {
Sentry.configureScope(scope => {
scope.setUser({ id: myUserId, username: myUserName });
});
const eventId = Sentry.captureException(error.originalError || error);
Sentry.showReportDialog({ eventId });
}
}Slides:
This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.