- 
                Notifications
    
You must be signed in to change notification settings  - Fork 819
 
feat(sdk): support multiple span processors #3207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from 12 commits
      Commits
    
    
            Show all changes
          
          
            13 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      ffb34b0
              
                feat(sdk): support multiple span processors
              
              
                doronkopit5 acddebc
              
                tests
              
              
                doronkopit5 3664304
              
                fixes + lint
              
              
                doronkopit5 28e2226
              
                fix tests
              
              
                doronkopit5 3bb8969
              
                refactor on_Start a bit
              
              
                doronkopit5 8551147
              
                lint
              
              
                doronkopit5 ac436a3
              
                cleaner
              
              
                doronkopit5 2144fb4
              
                closure bug
              
              
                doronkopit5 6df8242
              
                simplier
              
              
                doronkopit5 360c57e
              
                remove dups
              
              
                doronkopit5 5ba3d5a
              
                pythonic init
              
              
                doronkopit5 4b5bd9f
              
                fix tests
              
              
                doronkopit5 38094c1
              
                Merge branch 'main' into dk/sdk-multiple-span-processors-and-export-one
              
              
                nirga File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            35 changes: 35 additions & 0 deletions
          
          35 
        
  packages/sample-app/sample_app/multiple_span_processors.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from opentelemetry.sdk.trace.export import ConsoleSpanExporter | ||
| from opentelemetry.sdk.trace.export import SimpleSpanProcessor | ||
| from traceloop.sdk import Traceloop | ||
| from traceloop.sdk.decorators import task | ||
| from openai import OpenAI | ||
| import os | ||
| 
     | 
||
| client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) | ||
| 
     | 
||
| 
     | 
||
| traceloop_processor = Traceloop.get_default_span_processor(disable_batch=True) | ||
| 
     | 
||
| console_processor = SimpleSpanProcessor(ConsoleSpanExporter()) | ||
| 
     | 
||
| Traceloop.init(processor=[traceloop_processor, console_processor]) | ||
| 
     | 
||
| 
     | 
||
| @task(name="joke_creation", version=1) | ||
| def create_joke(): | ||
| completion = client.chat.completions.create( | ||
| model="gpt-3.5-turbo", | ||
| messages=[{"role": "user", "content": "Tell me a joke about opentelemetry multiple span processors"}], | ||
| ) | ||
| 
     | 
||
| result = completion.choices[0].message.content | ||
| print(result) | ||
| return result | ||
| 
     | 
||
| 
     | 
||
| def main(): | ||
| create_joke() | ||
| 
     | 
||
| 
     | 
||
| if __name__ == "__main__": | ||
| main() | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.