|
| 1 | +package datadog.trace.api.llmobs; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | +import java.util.Map; |
| 5 | + |
| 6 | +/** This interface represent an individual LLM Obs span. */ |
| 7 | +public interface LLMObsSpan { |
| 8 | + |
| 9 | + /** |
| 10 | + * Annotate the span with inputs and outputs |
| 11 | + * |
| 12 | + * @param inputData The input data of the span in the form of a list, for example a list of input |
| 13 | + * messages |
| 14 | + * @param outputData The output data of the span in the form of a list, for example a list of |
| 15 | + * output messages |
| 16 | + */ |
| 17 | + void annotateIO(List<Map<String, Object>> inputData, List<Map<String, Object>> outputData); |
| 18 | + |
| 19 | + /** |
| 20 | + * Annotate the span with inputs and outputs |
| 21 | + * |
| 22 | + * @param inputData The input data of the span in the form of a string |
| 23 | + * @param outputData The output data of the span in the form of a string |
| 24 | + */ |
| 25 | + void annotateIO(String inputData, String outputData); |
| 26 | + |
| 27 | + /** |
| 28 | + * Annotate the span with metadata |
| 29 | + * |
| 30 | + * @param metadata A map of JSON serializable key-value pairs that contains metadata information |
| 31 | + * relevant to the input or output operation described by the span |
| 32 | + */ |
| 33 | + void setMetadata(Map<String, Object> metadata); |
| 34 | + |
| 35 | + /** |
| 36 | + * Annotate the span with metrics |
| 37 | + * |
| 38 | + * @param metrics A map of JSON serializable keys and numeric values that users can add as metrics |
| 39 | + * relevant to the operation described by the span (input_tokens, output_tokens, total_tokens, |
| 40 | + * etc.). |
| 41 | + */ |
| 42 | + void setMetrics(Map<String, Number> metrics); |
| 43 | + |
| 44 | + /** |
| 45 | + * Annotate the span with a single metric key value pair for the span’s context (number of tokens |
| 46 | + * document length, etc). |
| 47 | + * |
| 48 | + * @param key the name of the metric |
| 49 | + * @param value the value of the metric |
| 50 | + */ |
| 51 | + void setMetric(CharSequence key, int value); |
| 52 | + |
| 53 | + /** |
| 54 | + * Annotate the span with a single metric key value pair for the span’s context (number of tokens |
| 55 | + * document length, etc). |
| 56 | + * |
| 57 | + * @param key the name of the metric |
| 58 | + * @param value the value of the metric |
| 59 | + */ |
| 60 | + void setMetric(CharSequence key, long value); |
| 61 | + |
| 62 | + /** |
| 63 | + * Annotate the span with a single metric key value pair for the span’s context (number of tokens |
| 64 | + * document length, etc). |
| 65 | + * |
| 66 | + * @param key the name of the metric |
| 67 | + * @param value the value of the metric |
| 68 | + */ |
| 69 | + void setMetric(CharSequence key, double value); |
| 70 | + |
| 71 | + /** |
| 72 | + * Annotate the span with tags |
| 73 | + * |
| 74 | + * @param tags An map of JSON serializable key-value pairs that users can add as tags regarding |
| 75 | + * the span’s context (session, environment, system, versioning, etc.). |
| 76 | + */ |
| 77 | + void setTags(Map<String, Object> tags); |
| 78 | + |
| 79 | + /** |
| 80 | + * Annotate the span with a single tag key value pair as a tag regarding the span’s context |
| 81 | + * (session, environment, system, versioning, etc.). |
| 82 | + * |
| 83 | + * @param key the key of the tag |
| 84 | + * @param value the value of the tag |
| 85 | + */ |
| 86 | + void setTag(String key, String value); |
| 87 | + |
| 88 | + /** |
| 89 | + * Annotate the span with a single tag key value pair as a tag regarding the span’s context |
| 90 | + * (session, environment, system, versioning, etc.). |
| 91 | + * |
| 92 | + * @param key the key of the tag |
| 93 | + * @param value the value of the tag |
| 94 | + */ |
| 95 | + void setTag(String key, boolean value); |
| 96 | + |
| 97 | + /** |
| 98 | + * Annotate the span with a single tag key value pair as a tag regarding the span’s context |
| 99 | + * (session, environment, system, versioning, etc.). |
| 100 | + * |
| 101 | + * @param key the key of the tag |
| 102 | + * @param value the value of the tag |
| 103 | + */ |
| 104 | + void setTag(String key, int value); |
| 105 | + |
| 106 | + /** |
| 107 | + * Annotate the span with a single tag key value pair as a tag regarding the span’s context |
| 108 | + * (session, environment, system, versioning, etc.). |
| 109 | + * |
| 110 | + * @param key the key of the tag |
| 111 | + * @param value the value of the tag |
| 112 | + */ |
| 113 | + void setTag(String key, long value); |
| 114 | + |
| 115 | + /** |
| 116 | + * Annotate the span with a single tag key value pair as a tag regarding the span’s context |
| 117 | + * (session, environment, system, versioning, etc.). |
| 118 | + * |
| 119 | + * @param key the key of the tag |
| 120 | + * @param value the value of the tag |
| 121 | + */ |
| 122 | + void setTag(String key, double value); |
| 123 | + |
| 124 | + /** |
| 125 | + * Annotate the span to indicate that an error occurred |
| 126 | + * |
| 127 | + * @param error whether an error occurred |
| 128 | + */ |
| 129 | + void setError(boolean error); |
| 130 | + |
| 131 | + /** |
| 132 | + * Annotate the span with an error message |
| 133 | + * |
| 134 | + * @param errorMessage the message of the error |
| 135 | + */ |
| 136 | + void setErrorMessage(String errorMessage); |
| 137 | + |
| 138 | + /** |
| 139 | + * Annotate the span with a throwable |
| 140 | + * |
| 141 | + * @param throwable the errored throwable |
| 142 | + */ |
| 143 | + void addThrowable(Throwable throwable); |
| 144 | + |
| 145 | + /** Finishes (closes) a span */ |
| 146 | + void finish(); |
| 147 | +} |
0 commit comments