UNPKG

@sentry/google-cloud-serverless

Version:
39 lines (35 loc) • 1.3 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); const GCP_CONTEXT_ATTRIBUTE_MAP = { type: "gcp.function.context.type", source: "gcp.function.context.source", id: "gcp.function.context.id", specversion: "gcp.function.context.specversion", time: "gcp.function.context.time", eventId: "gcp.function.context.event_id", timestamp: "gcp.function.context.timestamp", eventType: "gcp.function.context.event_type", resource: "gcp.function.context.resource" }; const _gcpContextIntegration = (() => { return { name: "GcpContext", processSegmentSpan(span) { const gcpContext = core.getCurrentScope().getScopeData().contexts["gcp.function.context"]; if (!gcpContext) { return; } const attrs = {}; for (const [field, attrName] of Object.entries(GCP_CONTEXT_ATTRIBUTE_MAP)) { const value = gcpContext[field]; if (typeof value === "string" || typeof value === "number") { attrs[attrName] = value; } } core.safeSetSpanJSONAttributes(span, attrs); } }; }); const gcpContextIntegration = core.defineIntegration(_gcpContextIntegration); exports.gcpContextIntegration = gcpContextIntegration; //# sourceMappingURL=gcp-context.js.map