Initialize
- TypeScript
- Python
Initialize Gentrace with the init()
function. This allows other Gentrace SDK functions to transparently authenticate
to Gentrace.
Arguments
apiKey
Authentication key string for API access. Create an API key here.
resultName?
Custom name of the test result that you want to appear in the Gentrace UI. Learn more about test results here.
branch?
Associate a Git branch with the test result.
commit?
Associate a Git commit with the test result.
api_key
Authentication key string for API access. Create an API key here.
result_name?
Custom name of the test result that you want to appear in the Gentrace UI. Learn more about test results here.
branch?
Associate a Git branch with the test result.
commit?
Associate a Git commit with the test result.
log_level?
Level of logging to display. For example, debug
, info
, warning
, etc.
Environmental variables
You can also set environmental variables rather than directly passing the arguments to the init()
function.
Example
Directly passing arguments:
typescript
import {init } from '@gentrace/core';init ({apiKey :process .env .GENTRACE_API_KEY ,resultName : "My Test Result",branch : "main",commit : "1234567890"});
Using environmental variables:
typescript
import {init } from '@gentrace/core';// Environmental variables (e.g. GENTRACE_API_KEY) are expected to available in// the process environment via a .env file, CI/CD environment primitives, etc.init ();
Directly passing arguments:
python
import osimport gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"),result_name="My Test Result",branch="main",commit="1234567890")
Using environmental variables:
python
import osimport gentracefrom dotenv import load_dotenv# You can load the environmental variables in the most convenient way for your# environment. For example, you can use a .env file, CI/CD environment primitives, etc.load_dotenv()gentrace.init()