001/*
002 * Copyright 2022-2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.soklet.otel;
018
019import com.soklet.McpEndpoint;
020import com.soklet.McpSseStream;
021import com.soklet.Request;
022import com.soklet.ResourceMethod;
023import com.soklet.SseConnection;
024import com.soklet.StreamingResponseHandle;
025import org.jspecify.annotations.NonNull;
026import org.jspecify.annotations.Nullable;
027
028import javax.annotation.concurrent.ThreadSafe;
029
030/**
031 * Customizes OpenTelemetry span names emitted by {@link OpenTelemetryLifecycleObserver}.
032 *
033 * @author <a href="https://www.revetkn.com">Mark Allen</a>
034 */
035@ThreadSafe
036public interface SpanNamingStrategy {
037        @NonNull
038        String httpRequestSpanName(@NonNull Request request,
039                                                                                                                 @Nullable ResourceMethod resourceMethod);
040
041        @NonNull
042        String streamingResponseSpanName(@NonNull StreamingResponseHandle stream);
043
044        @NonNull
045        String sseConnectionSpanName(@NonNull SseConnection connection);
046
047        @NonNull
048        String mcpRequestSpanName(@NonNull Request request,
049                                                                                                                @NonNull Class<? extends McpEndpoint> endpointClass,
050                                                                                                                @NonNull String jsonRpcMethod);
051
052        @NonNull
053        String mcpSseStreamSpanName(@NonNull McpSseStream stream);
054
055        @NonNull
056        static SpanNamingStrategy defaultInstance() {
057                return DefaultSpanNamingStrategy.defaultInstance();
058        }
059}