Skip to content

Commit b81b595

Browse files
authored
docs: typedoc for javascript modules (#2379)
1 parent 764030c commit b81b595

File tree

10 files changed

+278
-68
lines changed

10 files changed

+278
-68
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ sdist
1717
.safety-project.ini
1818
.mastra
1919

20+
# Generated docs
21+
js/**/docs
22+
2023
# Data files
2124
*.csv
2225
*.parquet

js/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
This is the JavaScript version of OpenInference, a framework for collecting traces from LLM applications.
44

5-
> [!NOTE]
6-
> Currently we only support OpenAI but we are working on adding support for other LLM frameworks and SDKs. If you are interested in contributing, please reach out to us by joining our slack community or opening an issue!
7-
85
## Installation
96

10-
OpenInference uses OpenTelemetry Protocol (OTLP) to send traces to a compatible backend (e.x. [arize-phoenix](<[https://git](https://github.com/Arize-ai/phoenix)>)). To use OpenInference, you will need to install the OpenTelemetry SDK and the OpenInference instrumentation for the LLM framework you are using.
7+
OpenInference uses OpenTelemetry Protocol (OTLP) to send traces to a compatible backend (e.x. [arize-phoenix](https://github.com/Arize-ai/phoenix)). To use OpenInference, you will need to install the OpenTelemetry SDK and the OpenInference instrumentation for the LLM framework you are using.
118

129
Install the OpenTelemetry SDK:
1310

js/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"type:check": "pnpm run -r type:check",
1414
"lint": "eslint .",
1515
"ci:version": "pnpm changeset version",
16-
"ci:publish": "pnpm run -r prebuild && pnpm run -r build && pnpm publish -r --access public --provenance"
16+
"ci:publish": "pnpm run -r prebuild && pnpm run -r build && pnpm publish -r --access public --provenance",
17+
"docs:generate": "typedoc",
18+
"docs:preview": "rimraf docs && pnpm docs:generate && pnpx http-server ./docs -p 8080 -o"
1719
},
1820
"keywords": [
1921
"telemetry",
@@ -32,6 +34,7 @@
3234
"prettier": "^3.6.2",
3335
"rimraf": "^5.0.9",
3436
"tsc-alias": "^1.8.10",
37+
"typedoc": "^0.28.14",
3538
"typescript": "^5.5.4",
3639
"typescript-eslint": "^8.46.2",
3740
"vitest": "^4.0.3"

js/packages/openinference-core/src/trace/trace-config/OITracer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export class OITracer implements Tracer {
5353
private readonly tracer: Tracer;
5454
private readonly config: TraceConfig;
5555
/**
56-
*
57-
* @param tracer The OpenTelemetry {@link Tracer} to wrap
58-
* @param traceConfig The {@link TraceConfigOptions} to set to control the behavior of the tracer
56+
* @param params - The parameters for the OITracer constructor
57+
* @param params.tracer - The OpenTelemetry {@link Tracer} to wrap
58+
* @param params.traceConfig - The {@link TraceConfigOptions} to set to control the behavior of the tracer
5959
*/
6060
constructor({
6161
tracer,

js/packages/openinference-core/src/trace/trace-config/maskingRules.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ const maskingRules: MaskingRule[] = [
205205

206206
/**
207207
* A function that masks (redacts or removes) sensitive information from span attributes based on the trace config.
208-
* @param config The {@link TraceConfig} to use to determine if the value should be masked
209-
* @param key The key of the attribute to mask
210-
* @param value The value of the attribute to mask
208+
* @param params - The masking parameters
209+
* @param params.config - The TraceConfig to use to determine if the value should be masked
210+
* @param params.key - The key of the attribute to mask
211+
* @param params.value - The value of the attribute to mask
211212
* @returns The redacted value or undefined if the value should be masked, otherwise the original value
212213
*/
213214
export function mask({

js/packages/openinference-core/src/trace/trace-config/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type TraceConfig = Readonly<Required<TraceConfigOptions>>;
2424

2525
export type TraceConfigKey = keyof TraceConfig;
2626

27-
type BooleanTraceConfigFlag = {
27+
export type BooleanTraceConfigFlag = {
2828
/**
2929
* The default value for the flag
3030
*/
@@ -39,7 +39,7 @@ type BooleanTraceConfigFlag = {
3939
type: "boolean";
4040
};
4141

42-
type NumericTraceConfigFlag = {
42+
export type NumericTraceConfigFlag = {
4343
/**
4444
* The default value for the flag
4545
*/

js/packages/openinference-genai/src/attributes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export const convertGenAISpanAttributesToOpenInferenceSpanAttributes = (
225225

226226
/**
227227
* Map provider and system to openinference attributes
228-
* @todo add some heuristics that can map incoming provider names to the correct OpenInference provider name
228+
* @remarks TODO: add some heuristics that can map incoming provider names to the correct OpenInference provider name
229229
* @param spanAttributes - The span attributes containing provider and system to map
230230
* @returns The mapped provider and system attributes
231231
*/

js/packages/openinference-vercel/src/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const getVercelFunctionNameFromOperationName = (
5151

5252
/**
5353
* Gets the OpenInference span kind that corresponds to the Vercel operation name
54-
* @param attributes the attributes of the span
54+
* @param attributes - The attributes of the span
5555
* @returns the OpenInference span kind associated with the attributes or null if not found
5656
*/
5757
const getOISpanKindFromAttributes = (
@@ -411,9 +411,7 @@ const safelyGetMetadataAttributes = withSafety({
411411

412412
/**
413413
* Gets the OpenInference attributes associated with the span from the initial attributes
414-
* @param attributesWithSpanKind the initial attributes of the span and the OpenInference span kind
415-
* @param attributesWithSpanKind.attributes the initial attributes of the span
416-
* @param attributesWithSpanKind.spanKind the OpenInference span kind
414+
* @param attributes - The initial attributes of the span
417415
* @returns The OpenInference attributes associated with the span
418416
*/
419417
const getOpenInferenceAttributes = (attributes: Attributes): Attributes => {
@@ -567,8 +565,9 @@ export const isOpenInferenceSpan = (span: ReadableSpan) => {
567565

568566
/**
569567
* Determines whether a span should be exported based on configuration and the spans attributes.
570-
* @param span the spn to check for export eligibility.
571-
* @param spanFilter a filter to apply to a span before exporting. If it returns true for a given span, the span will be exported.
568+
* @param params - The parameters object
569+
* @param params.span - The span to check for export eligibility
570+
* @param params.spanFilter - A filter to apply to a span before exporting. If it returns true for a given span, the span will be exported
572571
* @returns true if the span should be exported, false otherwise.
573572
*/
574573
export const shouldExportSpan = ({

0 commit comments

Comments
 (0)