forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTelemetryConfig.java
More file actions
149 lines (136 loc) · 4.26 KB
/
TelemetryConfig.java
File metadata and controls
149 lines (136 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
/**
* OpenTelemetry configuration for the Copilot CLI server.
* <p>
* When set on {@link CopilotClientOptions#setTelemetry(TelemetryConfig)}, the
* CLI server is started with OpenTelemetry instrumentation enabled using the
* provided settings.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var options = new CopilotClientOptions()
* .setTelemetry(new TelemetryConfig().setOtlpEndpoint("http://localhost:4318").setSourceName("my-app"));
* }</pre>
*
* @see CopilotClientOptions#setTelemetry(TelemetryConfig)
* @since 1.2.0
*/
public class TelemetryConfig {
private String otlpEndpoint;
private String filePath;
private String exporterType;
private String sourceName;
private Boolean captureContent;
/**
* Gets the OTLP exporter endpoint URL.
* <p>
* Maps to the {@code OTEL_EXPORTER_OTLP_ENDPOINT} environment variable.
*
* @return the OTLP endpoint URL, or {@code null}
*/
public String getOtlpEndpoint() {
return otlpEndpoint;
}
/**
* Sets the OTLP exporter endpoint URL.
*
* @param otlpEndpoint
* the endpoint URL (e.g., {@code "http://localhost:4318"})
* @return this config for method chaining
*/
public TelemetryConfig setOtlpEndpoint(String otlpEndpoint) {
this.otlpEndpoint = otlpEndpoint;
return this;
}
/**
* Gets the file path for the file exporter.
* <p>
* Maps to the {@code COPILOT_OTEL_FILE_EXPORTER_PATH} environment variable.
*
* @return the file path, or {@code null}
*/
public String getFilePath() {
return filePath;
}
/**
* Sets the file path for the file exporter.
*
* @param filePath
* the path where telemetry spans are written
* @return this config for method chaining
*/
public TelemetryConfig setFilePath(String filePath) {
this.filePath = filePath;
return this;
}
/**
* Gets the exporter type.
* <p>
* Maps to the {@code COPILOT_OTEL_EXPORTER_TYPE} environment variable.
*
* @return the exporter type (e.g., {@code "otlp-http"} or {@code "file"}), or
* {@code null}
*/
public String getExporterType() {
return exporterType;
}
/**
* Sets the exporter type.
*
* @param exporterType
* the exporter type ({@code "otlp-http"} or {@code "file"})
* @return this config for method chaining
*/
public TelemetryConfig setExporterType(String exporterType) {
this.exporterType = exporterType;
return this;
}
/**
* Gets the source name for telemetry spans.
* <p>
* Maps to the {@code COPILOT_OTEL_SOURCE_NAME} environment variable.
*
* @return the source name, or {@code null}
*/
public String getSourceName() {
return sourceName;
}
/**
* Sets the source name for telemetry spans.
*
* @param sourceName
* a name identifying the application producing the spans
* @return this config for method chaining
*/
public TelemetryConfig setSourceName(String sourceName) {
this.sourceName = sourceName;
return this;
}
/**
* Gets whether to capture message content as part of telemetry.
* <p>
* Maps to the {@code OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT}
* environment variable.
*
* @return {@code true} to capture content, {@code false} to suppress it, or
* {@code null} to use the default
*/
public Boolean getCaptureContent() {
return captureContent;
}
/**
* Sets whether to capture message content as part of telemetry.
*
* @param captureContent
* {@code true} to capture content, {@code false} to suppress it
* @return this config for method chaining
*/
public TelemetryConfig setCaptureContent(Boolean captureContent) {
this.captureContent = captureContent;
return this;
}
}