Skip to content

Commit

Permalink
fix: update package name to prevent collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-kurganskii committed Dec 31, 2024
1 parent bfd01db commit 6626bd2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bitvavo/faro-core",
"name": "@grafana/faro-core",
"version": "1.13.1-alpha.0",
"description": "Core package of Faro.",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { EventAttributes as FaroEventAttributes } from '@bitvavo/react-native-sdk';
import type { SpanContext } from '@opentelemetry/api';
import { ESpanKind, IResourceSpans } from '@opentelemetry/otlp-transformer';

import { faro, unknownString } from '@grafana/faro-core';
import type { EventAttributes as FaroEventAttributes } from '@grafana/react-native-sdk';

export function sendFaroEvents(resourceSpans: IResourceSpans[] = []) {
for (const resourceSpan of resourceSpans) {
Expand Down
57 changes: 27 additions & 30 deletions packages/react-native-tracing/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import {context, trace} from '@opentelemetry/api';
import {W3CTraceContextPropagator} from '@opentelemetry/core';
import {registerInstrumentations} from '@opentelemetry/instrumentation';
import {Resource, ResourceAttributes} from '@opentelemetry/resources';
import {BatchSpanProcessor, WebTracerProvider} from '@opentelemetry/sdk-trace-web';
import {ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION,} from '@opentelemetry/semantic-conventions';


import {BaseInstrumentation, Transport, VERSION} from '@grafana/react-native-sdk';

import {FaroTraceExporter} from './faroTraceExporter';
import {getDefaultOTELInstrumentations} from './getDefaultOTELInstrumentations';
import {getSamplingDecision} from './sampler';
import {FaroSessionSpanProcessor} from './sessionSpanProcessor';
import type {TracingInstrumentationOptions} from './types';
import { BaseInstrumentation, Transport, VERSION } from '@bitvavo/react-native-sdk';
import { context, trace } from '@opentelemetry/api';
import { W3CTraceContextPropagator } from '@opentelemetry/core';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource, ResourceAttributes } from '@opentelemetry/resources';
import { BatchSpanProcessor, WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';

import { FaroTraceExporter } from './faroTraceExporter';
import { getDefaultOTELInstrumentations } from './getDefaultOTELInstrumentations';
import { getSamplingDecision } from './sampler';
import { FaroSessionSpanProcessor } from './sessionSpanProcessor';
import type { TracingInstrumentationOptions } from './types';

// the providing of app name here is not great
// should delay initialization and provide the full Faro config,
Expand All @@ -36,7 +34,6 @@ export class TracingInstrumentation extends BaseInstrumentation {
attributes[ATTR_SERVICE_NAME] = this.config.app.name;
}


if (this.config.app.version) {
attributes[ATTR_SERVICE_VERSION] = this.config.app.version;
}
Expand All @@ -57,13 +54,13 @@ export class TracingInstrumentation extends BaseInstrumentation {
});

provider.addSpanProcessor(
options.spanProcessor ??
options.spanProcessor ??
new FaroSessionSpanProcessor(
new BatchSpanProcessor(new FaroTraceExporter({ api: this.api }), {
scheduledDelayMillis: TracingInstrumentation.SCHEDULED_BATCH_DELAY_MS,
maxExportBatchSize: 30,
}),
this.metas
new BatchSpanProcessor(new FaroTraceExporter({ api: this.api }), {
scheduledDelayMillis: TracingInstrumentation.SCHEDULED_BATCH_DELAY_MS,
maxExportBatchSize: 30,
}),
this.metas
)
);

Expand All @@ -73,17 +70,17 @@ export class TracingInstrumentation extends BaseInstrumentation {
});

const { propagateTraceHeaderCorsUrls, fetchInstrumentationOptions, xhrInstrumentationOptions } =
this.options.instrumentationOptions ?? {};
this.options.instrumentationOptions ?? {};

registerInstrumentations({
instrumentations:
options.instrumentations ??
getDefaultOTELInstrumentations({
ignoreUrls: this.getIgnoreUrls(),
propagateTraceHeaderCorsUrls,
fetchInstrumentationOptions,
xhrInstrumentationOptions,
}),
options.instrumentations ??
getDefaultOTELInstrumentations({
ignoreUrls: this.getIgnoreUrls(),
propagateTraceHeaderCorsUrls,
fetchInstrumentationOptions,
xhrInstrumentationOptions,
}),
});
this.api.initOTEL(trace, context);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react-native-tracing/src/sampler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { MetaSession } from '@bitvavo/react-native-sdk';
import { SamplingDecision } from '@opentelemetry/sdk-trace-web';

import type { MetaSession } from '@grafana/react-native-sdk';

export function getSamplingDecision(sessionMeta: MetaSession = {}): SamplingDecision {
const isSessionSampled = sessionMeta.attributes?.['isSampled'] === 'true';
const samplingDecision = isSessionSampled ? SamplingDecision.RECORD_AND_SAMPLED : SamplingDecision.NOT_RECORD;
Expand Down
5 changes: 2 additions & 3 deletions packages/react-native-tracing/src/sessionSpanProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Metas } from '@bitvavo/react-native-sdk';
import type { Context } from '@opentelemetry/api';
import type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-web';

import type { Metas } from '@grafana/react-native-sdk';

export class FaroSessionSpanProcessor implements SpanProcessor {
constructor(
private processor: SpanProcessor,
Expand All @@ -17,7 +16,7 @@ export class FaroSessionSpanProcessor implements SpanProcessor {
const session = this.metas.value.session;

if (session?.id) {
span.attributes["session.id"] = session.id;
span.attributes['session.id'] = session.id;
/**
* @deprecated will be removed in the future and has been replaced by ATTR_SESSION_ID (session.id)
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-tracing/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { API } from '@bitvavo/react-native-sdk';
import type { ContextManager, TextMapPropagator } from '@opentelemetry/api';
import type { Instrumentation } from '@opentelemetry/instrumentation';
import type { FetchCustomAttributeFunction } from '@opentelemetry/instrumentation-fetch';
Expand All @@ -6,7 +7,6 @@ import type { ResourceAttributes } from '@opentelemetry/resources';
import type { SpanProcessor } from '@opentelemetry/sdk-trace-web';

import type { Patterns } from '@grafana/faro-core';
import type { API } from '@grafana/react-native-sdk';

// type got remove by with experimental/v0.52.0 and is replaced by the following type:
// See: https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.52.0
Expand Down
2 changes: 1 addition & 1 deletion packages/web-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bitvavo/faro-web-sdk",
"name": "@grafana/faro-web-sdk",
"version": "1.13.1-alpha.0",
"description": "Faro instrumentations, metas, transports for web.",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/web-tracing/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bitvavo/faro-web-tracing",
"name": "@grafana/faro-web-tracing",
"version": "1.13.1-alpha.0",
"description": "Faro web tracing implementation.",
"keywords": [
Expand Down

0 comments on commit 6626bd2

Please sign in to comment.