Skip to content

Commit

Permalink
chore: correct sampler and new Resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed Jun 29, 2023
1 parent 937a95b commit ee96ab7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/_internal/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// 🚨 WARNING THIS FILE WILL DUPLICATE ITSELF WITH EACH ENTRYPOINT

import type { Context, Exporter, ScopedSpans, Span } from 'rian';
import type { Resource, Context, Exporter, ScopedSpans, Span } from 'rian';
import { is_sampled, type Traceparent } from 'tctx';

// ---

let resource: Context = {};
let resource = {} as Resource;

export function configure(name: string, attributes: Context = {}) {
resource = {
Expand Down
22 changes: 15 additions & 7 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import type { Traceparent } from 'tctx';
/**
* The exporter is called when the {@link report} method is called.
*/
export type Exporter = (trace: {
resource: Context;
export type Exporter = (trace: Trace) => any;

type Resource = {
'service.name': string;
'telemetry.sdk.name': string;
'telemetry.sdk.version': string;
} & Context;

export type Trace = {
resource: Resource;
scopeSpans: IterableIterator<ScopedSpans>;
}) => any;
};

export type ScopedSpans = {
readonly scope: { readonly name: string };
Expand Down Expand Up @@ -43,15 +51,15 @@ export type Sampler = (
/**
* The name of the span.
*/
readonly name: string,
name: string,
/**
* The traceparent id of the span.
*/
readonly id: Traceparent,
id: Traceparent,
/**
* The tracer this span belongs to.
*/
readonly tracer: { readonly name: string },
tracer: { readonly name: string },
) => boolean;

// --- spans
Expand Down Expand Up @@ -229,7 +237,7 @@ export async function report<T extends Exporter>(
* configure('my-service', { 'deployment.environment': 'production', 'k8s.namespace.name': 'default' });
* ```
*/
export function configure(name: string, attributes: Context = {}): void;
export function configure(name: string, attributes: Context): void;

/**
* Provinding a clock allows you to control the time of the span.
Expand Down

0 comments on commit ee96ab7

Please sign in to comment.